package com.clkj.xiuzheng.dao.shangcheng;

import com.clkj.xiuzheng.pojo.shangcheng.PromoterApply;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface PromoterApplyMapper extends Mapper<PromoterApply> {
    //"select p.*,u.user_name,c.company_name from t_xz_promoterApply p left join t_xz_user u on p.user_id = u.user_id left join t_xz_productCompany c  on p.company_id =c.company_id  where  p.company_id = #{companyId}")
    @Select({"<script>",
            "select p.*,u.user_name,c.company_name from t_xz_promoterApply p left join t_xz_user u on p.user_id = u.user_id left join t_xz_productCompany c  on p.company_id =c.company_id",
            "where p.company_id = #{companyId} and p.apply_status = #{type}",
            "</script>"
    })
    List<PromoterApply> getPromoterApplyList(@Param("companyId") Integer companyId, Integer type);

    @Select({"<script>",
            "select p.*,u.user_name,c.company_name from t_xz_promoterApply p left join t_xz_user u on p.user_id = u.user_id left join t_xz_productCompany c  on p.company_id =c.company_id where p.apply_status = #{type}",
            "</script>"
    })
    List<PromoterApply> getPromoterAllApplyList(Integer type);

    @Select("select * from t_xz_promoterApply where company_id = #{id} and apply_status=0 and company_opinion=1 and main_company_opinion=0 order by handle_time desc")
    List<PromoterApply> getPromoUserList(Integer id);
    @Select("select * from t_xz_promoterApply where company_id = #{id} and apply_status=1 and company_opinion=0 order by handle_time desc")
    List<PromoterApply> getPromoUserListById(Integer companyId);
}
